/*
 heat-spectral lib. solves time-dependent PDEs using SEM-NI method.
 Copyright (C) 2009, Altieri Michele and Stefanoni Andrea
 Copyright (C) 2008, Proverbio Alessandro and Radice David

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
 * \file solution.hpp
 * \brief This file contains the Solution class
 *
 * The Solution class is to be used to perform post-processing
 * or error estimates on the computed numerical solution
 */

# ifndef SOLUTION_HPP
# define SOLUTION_HPP 1

# include<cmath>
# include<valarray>

# include "integrator.hpp"
# include "point.hpp"
# include "typedefs.hpp"

namespace spectral {

/**
 * \class Solution
 * \brief Class useful for managing the solution
 */

/**
 * \fn Solution::Solution(double const * const & u,
			  int element,
			  Mesh const & me)
   \brief The Solution class constructor
   \param u Solution
   \param element Number of element corresponding at the solution
   \param me Mesh
*/

/**
 * \fn Solution::Solution(Solution const & u)
 * \brief The Solution class copy constructor
   \param u Class to be copied
*/

/**
 * \fn Solution()
 * \brief Default constructor
 */

/**
 * \fn double Solution::operator()(double const & x,double const & y) const
 * \brief The evaluator
   \param x x-position
   \param y y-position
*/

/**
 * \fn void Solution::Dx(int elemnum)
 * \brief Derivates the solution along x
   \param elemnum The element of reference
*/

/**
 * \fn void Solution::Dy(int elemnum)
 * \brief Derivates the solution along y
   \param elemnum The element of reference
*/

/// Forward declaration of Mesh
class Mesh;

class Solution {
    public:
        Solution(double const * const & u,
                 int element,
                 Mesh const & me);
        Solution(Solution const & u);
        ~Solution();

        double operator()(double const & x,double const & y) const;

        void Dx(int elemnum);
        void Dy(int elemnum);
    private:
        double * _weights;    /**< \brief Weights for integration */
        TensorProd * _base;   /**< \brief Base function */
        int _nnodes;          /**< \brief Numer of nodes */
        int _size;            /**< \brief Subproblem dimension */
        Mesh const & _me;     /**< \brief Mesh */
        int _element;         /**< \brief Element number */
};

} // namespace

// This is here to avoid circular dependancies
// problems:
# include "mesh.hpp"

# endif
